<script type='text/javascript' src="<?php echo Yii::app()->theme->baseUrl; ?>/js/swfupload/swfupload.js"></script>
<script type='text/javascript' src="<?php echo Yii::app()->theme->baseUrl; ?>/js/jquery.swfupload.js"></script>
<script type="text/javascript">
$(document).ready(function() {
	$(".popupCancel").click(function() {
		$.fancybox.close();
		});
	$("#selectCategory").change(function(){
		if($(this).val() == 3)
			$("#addNewCategory").show();
		else $("#addNewCategory").hide();
		});
	$("#fileNewCategoroy").hide();
	$("#fileEditCategory").change(function(){
		if($(this).val() == 3)
			$("#fileNewCategoroy").show();
		else $("#fileNewCategoroy").hide();
		});
});

$(function(){
	$('#swfupload-control').swfupload({
		upload_url: "<?php echo Yii::app()->theme->baseUrl; ?>/upload-file.php",
		file_post_name: 'uploadfile',
		file_size_limit : "5120",
		file_types : "*.jpg;*.png;*.gif;*.doc;*.docx;*.pdf;*.xls;*xlsx;*.rar",
		file_types_description : "Image files",
		file_upload_limit : 5,
		flash_url : "<?php echo Yii::app()->theme->baseUrl; ?>/js/swfupload/swfupload.swf",
		button_image_url : '<?php echo Yii::app()->theme->baseUrl; ?>/js/swfupload/wdp_buttons_upload_114x29.png',
		button_width : 114,
		button_height : 29,
		button_placeholder : $('#button')[0],
		debug: true
	})
		.bind('fileQueued', function(event, file){
			var listitem='<li id="'+file.id+'" >'+
				'File: <em>'+file.name+'</em> ('+Math.round(file.size/1024)+' KB) <span class="progressvalue" ></span>'+
				'<div class="progressbar" ><div class="progress" ></div></div>'+
				'<p class="status" >Pending</p>'+
				'<span class="cancel" >&nbsp;</span>'+
				'</li>';
			$('#log').append(listitem);
			$('li#'+file.id+' .cancel').bind('click', function(){
				var swfu = $.swfupload.getInstance('#swfupload-control');
				swfu.cancelUpload(file.id);
				$('li#'+file.id).slideUp('fast');
			});
			// start the upload since it's queued
			$(this).swfupload('startUpload');
		})
		.bind('fileQueueError', function(event, file, errorCode, message){
			alert('Size of the file '+file.name+' is greater than limit');
		})
		.bind('fileDialogComplete', function(event, numFilesSelected, numFilesQueued){
			$('#queuestatus').text('Files Selected: '+numFilesSelected+' / Queued Files: '+numFilesQueued);
		})
		.bind('uploadStart', function(event, file){
			$('#log li#'+file.id).find('p.status').text('Uploading...');
			$('#log li#'+file.id).find('span.progressvalue').text('0%');
			$('#log li#'+file.id).find('span.cancel').hide();
		})
		.bind('uploadProgress', function(event, file, bytesLoaded){
			//Show Progress
			var percentage=Math.round((bytesLoaded/file.size)*100);
			$('#log li#'+file.id).find('div.progress').css('width', percentage+'%');
			$('#log li#'+file.id).find('span.progressvalue').text(percentage+'%');
		})
		.bind('uploadSuccess', function(event, file, serverData){
			var item=$('#log li#'+file.id);
			item.find('div.progress').css('width', '100%');
			item.find('span.progressvalue').text('100%');
			var pathtofile='<a href="<?php echo Yii::app()->theme->baseUrl; ?>/uploads/'+file.name+'" target="_blank" >view &raquo;</a>';
			item.addClass('success').find('p.status').html('Done!!! | '+pathtofile);
		})
		.bind('uploadComplete', function(event, file){
			// upload has completed, try the next one in the queue
			$(this).swfupload('startUpload');
		})
	
});	

</script>

<div class="clear"></div>
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->theme->baseUrl; ?>/css/file.css" />
<div id="than">	
           	 <img src="<?php echo Html::imageUrl("muiten.png");?>" width="27" height="26"; style="float:left">
            	<div id="textxanhdam">Message </div>
                 
		
      </div>
             	<div class="padding15"></div>                    	
            	<!-- Begin leftSidebar -->                  
              	<div id="leftSidebar">
              		<div id="leftWrapper">
						<button type="button">Upload files</button>
						<div class="padding20"></div>
						<h3>Category</h3>
						<ul>
							<li><a href="">Announcements</a></li>
							<li><a href="">Experiment</a></li>
						</ul>
						
						<div class="padding20"></div>
						<h3>File space</h3>
						Free Space: 5.39 MB
						<div class="padding5"></div>
						This project uses: 657kb
					</div>
				</div>
             	<!-- End leftSidebar-->
             	
                <!-- Begin rightSidebar-->
               	<div  id="rightSidebar">                      
					<div id="rightHeader">
						<h2>Files for this project</h2>
						<button type="button" id="rightHeaderBtn" href="#fileUpload">Upload files</button>
					</div>
					<div id="rightWrapper">
						<div class="fileRow">
							<div class="fileRowHeader">
								<h3>Wednesday, 29 June 2011</h3>
							</div>
							<img class="fileTypeImg" src="<?php echo Html::imageUrl("file_xls.gif");?>" />
							<div class="fileMain">
								<a class="fileName" href="<?php echo $this->createUrl('/files/detail')?>"><h3>Xman - Dự kiến - góp ý.xlsx</h3></a>
								<a href="">View</a> &#183
								<a href="">Download</a> &#183
								<a href="#fileEdit" class="fileEditLink">Edit</a>
								<div class="padding20"></div>
								Uploadded by <a href="" class="fileAuthor">Đặng Thanh Tú</a> in <a href="">Design</a> on Wednesday, 29 June 2011 21:188PM - 13Kb
							</div>
						</div>
						
						<div class="padding20"></div>
						
						<div class="fileRow">
							<div class="fileRowHeader">
								<h3>Tuesday, 21 June 2011</h3>
							</div>
							<img class="fileTypeImg" src="<?php echo Html::imageUrl("file_file.gif");?>" />
							<div class="fileMain">
								<a href="#"><h3>Xman_alpha_2.sql</h3></a>
								<p>Bản alpha 2. (Thêm trường user_is_admin trong bảng user)</p>
								<a href="">View</a> &#183
								<a href="">Download</a> &#183
								<a href="">Edit</a>
								<div class="padding20"></div>
								Uploadded by <a href="" class="fileAuthor">Bùi Xuân Sơn</a> in <a href="">CODE</a> on Tuesday, 21 June 2011 14:33PM · 26Kb
							</div>
						</div>
						
						<div class="padding20"></div>
						
						<div class="fileRow">
							<div class="fileRowHeader">
								<h3>Friday, 17 June 2011</h3>
							</div>
							<img class="fileTypeImg" src="<?php echo Html::imageUrl("file_zip.gif");?>" />
							<div class="fileMain">
								<a href="#"><h3>Xman.zip</h3></a>
								<p>CODE tu sinh project Xman : - Thanh phan: + 27 phuong thuc model cho 27 table trong DB - Huong dan config : 
								+ Tạo DB trong phpmyadmin : Xman ( charset : utf8_general_ci) + Import file .sql cua Son vao DB + Giai nen 
								forlder trong localhost , chmod 777 (trong Linux)/ set full permission (trong Windows) + Config trong file : 
								Xman/protected/config/main.php dong so 55 -> 60 , doi lai user vs password trong DB</p>
								<a href="">View</a> &#183
								<a href="">Download</a> &#183
								<a href="">Edit</a>
								<div class="padding20"></div>
								Uploadded by <a href="" class="fileAuthor">Trần Huy Chung</a> in <a href="">CODE</a> on Friday, 17 June 2011 16:46PM · 387Kb
							</div>
						</div>
						<div class="fileRow">
							<img class="fileTypeImg" src="<?php echo Html::imageUrl("file_xls.gif");?>" />
							<div class="fileMain">
								<a href="#"><h3>E-R diagram2.xlsx</h3></a>
								<p>Biểu đồ thực thể liên kết.</p>
								<a href="">View</a> &#183
								<a href="">Download</a> &#183
								<a href="">Edit</a>
								<div class="padding20"></div>
								Uploadded by <a href="" class="fileAuthor">Bùi Xuân Sơn</a> in <a href="">Design</a> on Friday, 17 June 2011 15:25PM · 26Kb
							</div>
						</div>
						
					</div>	
				<!-- End rightSidebar-->	
                </div>
                
                    
             </div>    
            
    <!--Kết thúc Phần Thân Nội Dung-->
    
    <!--  Begin file upload popup -->
    <div id="fileUploadPopup" style="display:none">
    	<div id="fileUpload" class="popupWrapper" method="post" action="">
    		<div class="popupHeader">
	    		<h2>Upload files</h2>
	    	</div>
	    	<div class="popupContent">
	    		<p>Select file to upload</p>
	    		<div class="padding5"></div>
	    		    
	    		<form method="post" action="updateDetail">
	    			<!-- Code upload file -->
	    			<div id="swfupload-control">  
				        <p>Upload upto 5 image files(jpg, png, gif), each having maximum size of 1MB</p>  
				        <input type="button" id="button" />  
				        <p id="queuestatus" ></p>  
				        <ol id="log"></ol>  
				    </div>
				    <div class="padding10"></div>
				    <p>Category</p>
				    <select id="selectCategory">
				    	<option value="1" SELECTED>Database</option>
				    	<option value="2">Tài liệu</option>
				    	<option value="3">- Add new category -</option>
				    </select>
				      
	    			<div class="padding10"></div>
	    			
	    			<div id="addNewCategory"  style="display: none;">
						<p>New Category</p> 
						<div class="padding5"></div>
						<input type="text" size="50px"></input>
						<div class="padding10"></div>
					</div>
								
	    			<div class="postButton">
		    			<input type="submit" value="Update details" /> or
		    			<a href="#" class="popupCancel" id="cancel">Cancel</a>
		    		</div>
	    		</form>
	    	</div>
    	</div>
    </div>
     <!--  end file upload popup -->
     <?php  $this->widget('application.extensions.fancybox.EFancyBox', array( 'target'=>'button#rightHeaderBtn', 'config'=>array( 'scrolling' => 'no', 'titleShow' => false, 'hideOnOverlayClick' =>false ), ) ); ?>
     
    <!-- Edit popup -->
    <div id="fileEditPopup" style="display: none">
    	<div id="fileEdit" class="popupWrapper" method="post">
    		<div class="popupHeader">
    			<h2>Edit file details</h2>
    		</div>
    		<div class="padding20"></div>
    		<div class="popupContent">
	    		<form action="" method="post">
	    			<p>Display name</p>
	    			<div class="padding5"></div>
	    			<input type="text" id="fileEditName"></input>
	    			<div class="padding20"></div>
	    			<p>Category</p>
	    			<div class="padding5"></div>
	    			<select id="fileEditCategory">
	    				<option value="1">Design</option>
	    				<option value="2">SQL</option>
	    				<option value="3">- New Category -</option>
	    			</select>
	    			<div id="fileNewCategoroy">
	    				<div class="padding10"></div>
	    				<p>New category</p>
	    				<div class="padding5"></div>
	    				<input type="text" id="fileEditCatName"></input>
	    			</div>
	    			<div class="padding10"></div>
	    			<div class="postButton">
		    			<input type="submit" value="Save changes" /> or
		    			<a href="#" class="popupCancel" id="cancel">Cancel</a>
		    		</div>
	    		</form>
    		</div>
    		
    	</div> 
    </div>
    <!-- End edit popup -->
    <?php  $this->widget('application.extensions.fancybox.EFancyBox', array( 'target'=>'a.fileEditLink', 'config'=>array( 'scrolling' => 'no', 'titleShow' => false, 'hideOnOverlayClick' =>false ), ) ); ?>